var Minio = require('minio')
var Fs = require('fs')

var minioClient = new Minio.Client({
  endPoint: '192.168.37.81',
  port: 9001,
  useSSL: false,
  accessKey: 'gG5MU8YFAo297XXnmywk',
  secretKey: 'jdl3omUzYnGqAEbvNFIqOydYuMfHmnoXx08sGnGf',
})

// minioClient.makeBucket('iostorage-res',  function (err) {
//     if (err) return console.log('Error creating bucket.', err)
//     console.log('Bucket created successfully in "cn".')
//   })

// var file = './package.json'
// var fileStream = Fs.createReadStream(file)
// var fileStat = Fs.stat(file, function (err, stats) {
//   if (err) {
//     return console.log(err)
//   }
//   minioClient.putObject('istorage-pub', '40mbfile.json', fileStream, stats.size, function (err, objInfo) {
//     if (err) {
//       return console.log(err) // err should be null
//     }
//     console.log('Success', objInfo)
//   })
// })

var path = `${__dirname}/demo/d.json`
console.log('path: ', path);
var metaData = {
  'Content-Type': 'text/html',
  'Content-Language': 123,
  'X-Amz-Meta-Testing': 1234,
  example: 5678,
}
minioClient.fPutObject('istorage-pub', 'd', path, metaData, function (err, objInfo) {
  if (err) {
    return console.log(err)
  }
  console.log('Success111', objInfo.etag, objInfo.versionId)
})